﻿/*******************************************************************************
 * Copyright © 2016
 * 
 * Description: MVC快速开发平台  FROM http://xmwxgn.com
 *
*********************************************************************************/
using ZFine.Code;
using ZFine.Domain.Entity.Gas;
using ZFine.Domain.IRepository.Gas;
using ZFine.Repository.Gas;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data.Common;
using ZFine.Domain.Entity.SystemManage;
using ZFine.Application.SystemManage;

namespace ZFine.Application.Gas
{
    public class PwdKeyApp
    {
        private IPwdKeyRepository service = new PwdKeyRepository();

        /// <summary>
        /// 客户端插入
        /// </summary>
        /// <param name="pwdKeyEntity"></param>
        public void ClientInsert(PwdKeyEntity pwdKeyEntity)
        {
            pwdKeyEntity.ClientCreate();
            service.Insert(pwdKeyEntity);
        }
        public List<PwdKeyEntity> GetList(Pagination pagination)
        {
            var expression = ExtLinq.True<PwdKeyEntity>();
            return service.FindList(expression, pagination);
        }
        /// <summary>
        /// 获得IQueryable
        /// </summary>
        /// <returns></returns>
        public IQueryable<PwdKeyEntity> GetIQueryable()
        {
            return service.IQueryable();
        }
        public int GetCount()
        {
            return service.IQueryable().Count();
        }
        public PwdKeyEntity GetForm(string keyValue)
        {
            return service.FindEntity(keyValue);
        }
        //提交
        public void SubmitForm(PwdKeyEntity organizeEntity, string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                organizeEntity.Modify(keyValue);
                service.Update(organizeEntity);
            }
            else
            {
                organizeEntity.Create();
                service.Insert(organizeEntity);
            }
        }
        //删除
        public void Del(string keyValue)
        {
            service.Delete(a => a.F_Id == keyValue);
        }
        //更新
        public void Update(PwdKeyEntity pwdKeyEntity)
        {
            service.Update(pwdKeyEntity);
        }
    }
}
